// 服务记录 仓库
import { createSlice } from "@reduxjs/toolkit";

export const serviceRecord = createSlice({
  name: "serviceRecord",
  initialState: {
    // 数据
    sList: [],
  },
  reducers: {
    sListSet: (state, action) => {
      state.sList = action.payload;
      console.log(action.payload);
    },
    // 搜索
    searchSet: (state, action) => {
      state.sList = state.sList.filter((item, index) => {
        return item.name.includes(action.payload);
      });
    },
  },
});
// 每个 case reducer 函数会生成对应的 Action creators
export const { sListSet, searchSet } = serviceRecord.actions;

export default serviceRecord.reducer;
